package com.vctgo.system.controller;

import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletResponse;

import com.vctgo.common.redis.service.RedisService;
import com.vctgo.system.domain.Chinas;
import com.vctgo.system.service.ChinasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vctgo.common.log.annotation.Log;
import com.vctgo.common.log.enums.BusinessType;
import com.vctgo.common.security.annotation.RequiresPermissions;
import com.vctgo.system.domain.TAccount;
import com.vctgo.system.service.ITAccountService;
import com.vctgo.common.core.web.controller.BaseController;
import com.vctgo.common.core.web.domain.AjaxResult;
import com.vctgo.common.core.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 * 账套详细Controller
 *
 * @author vctgo
 * @date 2024-12-17
 */
@RestController
@RequestMapping("account")
public class TAccountController extends BaseController
{
    @Autowired
    private ITAccountService tAccountService;

    @Autowired
    private ChinasService chinasService;

    @Autowired
    private RedisService redisService;



    /**
     * 查询账套详细列表
     */
    @RequiresPermissions("system:account:list")
    @GetMapping("/list")
    public AjaxResult list(TAccount tAccount)
    {
        IPage<TAccount> list = tAccountService.selectTAccountPage(tAccount);
        return AjaxResult.success(list);
    }

    @RequiresPermissions("system:account:chinas")
    @GetMapping("/chinas")
    public AjaxResult chinas()
    {
        List<Chinas> chinasList = chinasService.getRegions();


        return AjaxResult.success(chinasList);
    }

    /**
     * 查询模块副表
     */

    /**
     * 导出账套详细列表
     */
    @RequiresPermissions("system:account:export")
    @Log(title = "账套详细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TAccount tAccount)
    {
        List<TAccount> list = tAccountService.selectTAccountList(tAccount);
        ExcelUtil<TAccount> util = new ExcelUtil<TAccount>(TAccount.class);
        util.exportExcel(response, list, "账套详细数据");
    }

    /**
     * 获取账套详细详细信息
     */
    @RequiresPermissions("system:account:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(tAccountService.selectTAccountById(id));
    }

    /**
     * 新增账套详细
     */
    @RequiresPermissions("system:account:add")
    @Log(title = "账套详细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAccount tAccount)
    {



        return toAjax(tAccountService.insertTAccount(tAccount));
    }

    /**
     * 修改账套详细
     */
    @RequiresPermissions("system:account:edit")
    @Log(title = "账套详细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAccount tAccount)
    {
        return toAjax(tAccountService.updateTAccount(tAccount));
    }

    /**
     * 删除账套详细
     */
    @RequiresPermissions("system:account:remove")
    @Log(title = "账套详细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(tAccountService.deleteTAccountByIds(ids));
    }



}
